package gdma.hqdes.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import gdma.hqdes.bean.Unit;
import gdma.hqdes.bean.UnitStat;
import gdma.hqdes.bean.YearStat;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

@Mapper
public interface UnitMapper extends BaseMapper<Unit> {

    @Select("select u.id from unit u where u.scope=#{scope}")
    List<Long> getUnitIds(int scope);

    @Select("select * from unit u where u.parent_id=#{parentUnitId}")
    List<Unit> getChildUnits(long parentUnitId);

    List<UnitStat> statUnitScores(int scope, long projectId, Collection<Long> unitIds, Collection<Long> indexIds);

    List<YearStat> statHistoryUnitScores(Collection<Long> projectIds, Collection<Long> unitIds, Collection<Long> indexIds);

    List<UnitStat> notifyUnitScoresToReport(long projectId, int scope, int verId, Collection<Long> unitIds, Collection<String> roles);

    List<UnitStat> notifyUnitScoresToAudit(long projectId, int scope, int verId, Collection<Long> unitIds, Collection<String> roles, int auditLevel);

    List<Unit> listRecentUpdatedUnits(long projectId, int scope, int verId, Collection<Long> unitIds, String name, String areaTag, Collection<Long> notifyingUnitIds);

}
